#!/bin/sh
echo $0 $*

GAMEDIR=${PWD}
echo ==========GAMEDIR is $GAMEDIR
controlfolder="../PortMaster"

source $controlfolder/control.txt
#source $controlfolder/tasksetter

get_controls

gamedir="$GAMEDIR"
cd "$gamedir"

$ESUDO chmod 666 /dev/tty1
$ESUDO rm -rf ~/.local/share/VVVVVV
ln -s $gamedir ~/.local/share/
$ESUDO $controlfolder/oga_controls VVVVVV $param_device &
SDL_GAMECONTROLLERCONFIG="$sdl_controllerconfig" ./VVVVVV 2>&1 | tee $GAMEDIR/log.txt
$ESUDO kill -9 $(pidof oga_controls)
$ESUDO systemctl restart oga_events &
printf "\033c" >> /dev/tty1